using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class DoctorExtMap : EntityTypeConfiguration<DoctorExt>
	{
		public DoctorExtMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.TitleBeforeName)
				.HasMaxLength(50);
				
			this.Property(t => t.FullName)
				.HasMaxLength(50);
				
			this.Property(t => t.TitleAfterName)
				.HasMaxLength(50);
				
			this.Property(t => t.Specialist)
				.HasMaxLength(50);
				
			this.Property(t => t.MedicalCouncil)
				.HasMaxLength(50);
				
			this.Property(t => t.Phone)
				.HasMaxLength(50);
				
			this.Property(t => t.Mobile)
				.HasMaxLength(50);
				
			this.Property(t => t.Email)
				.HasMaxLength(50);
				
			this.Property(t => t.ReferalInstitution)
				.HasMaxLength(50);
				
			this.Property(t => t.DoctorCode)
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("DoctorExts");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.TitleBeforeName).HasColumnName("TitleBeforeName");
			this.Property(t => t.FullName).HasColumnName("FullName");
			this.Property(t => t.TitleAfterName).HasColumnName("TitleAfterName");
			this.Property(t => t.Specialist).HasColumnName("Specialist");
			this.Property(t => t.MedicalCouncil).HasColumnName("MedicalCouncil");
			this.Property(t => t.Phone).HasColumnName("Phone");
			this.Property(t => t.Mobile).HasColumnName("Mobile");
			this.Property(t => t.Email).HasColumnName("Email");
			this.Property(t => t.ReferalInstitution).HasColumnName("ReferalInstitution");
			this.Property(t => t.DoctorCode).HasColumnName("DoctorCode");
			this.Property(t => t.RefInstitutionId).HasColumnName("RefInstitutionId");

			// Relationships
			this.HasOptional(t => t.RefInstitutionType)
				.WithMany(t => t.DoctorExts)
				.HasForeignKey(d => d.RefInstitutionId);
				
		}
	}
}

